package scripts.sea;

import api.sea.FileUploadApi;
import api.sea.LoginApi;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.annotations.Test;
import util.AssertUtil;
import util.HttpClientUtils;
import util.ResponseData;
import java.io.IOException;
import java.net.URISyntaxException;

/**
 *委托单批量导入  正向和反向接口测试
 */
public class TestSeaFile {
    private final FileUploadApi fileUploadApi=new FileUploadApi();
    private static final Logger logger= LoggerFactory.getLogger(TestSeaFile.class);
    private static String data;
    @Test
    public void test_01() throws IOException, URISyntaxException {
        ResponseData responseData = LoginApi.login("admin", "qf123456?");
        data = responseData.getBody().getJSONObject("data").getString("logistics-token");

    }
    @Test
    public void test_02() throws IOException {
        HttpClientUtils.build_header("logistics-token",data);
        ResponseData responseData = fileUploadApi.sea_file("/excel/success.xlsx");
        logger.info("responseData={}",responseData);
        AssertUtil.assertCommon(responseData,200,"成功");
    }
    @Test
    public void test_03() throws IOException {
        HttpClientUtils.build_header("logistics-token",data);
        ResponseData responseData = fileUploadApi.sea_file("/excel/error.xlsx");
        logger.info("responseData={}",responseData);
        AssertUtil.assertCommon(responseData,200,"第(5)行品名不能为空");
    }

}
